package com.wfx.controller;


import com.wfx.entity.CmsContent;
import com.wfx.entity.PageDTO;
import com.wfx.entity.PageResult;
import com.wfx.entity.Result;
import com.wfx.service.ICmsContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zhu
 * @since 2021-01-23
 */
@RestController
@RequestMapping("/cmsContent")
@CrossOrigin
public class CmsContentController {

    @Autowired
    private ICmsContentService iCmsContentService;

    @RequestMapping("/search")
    @PreAuthorize("hasAnyRole('ROLE_ADMIN')")
    public PageResult<CmsContent> search(@RequestBody PageDTO<CmsContent> pageDTO){
      return   iCmsContentService.search(pageDTO);
    }


    //修改和添加
    @RequestMapping("/upAndAdd")
    @PreAuthorize("hasAnyRole('ROLE_ADMIN')")
    public Result upAndAdd(@RequestBody CmsContent cmsContent){
        return iCmsContentService.upAndAdd(cmsContent);
    }

    //删除
    @RequestMapping("/del")
    @PreAuthorize("hasAnyRole('ROLE_ADMIN')")
    public Result del(@RequestBody  List<String> ids){
        return iCmsContentService.del(ids);

    }



}
